package com.service;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.SqlSession;

import com.dao.ArchiveDao;
import com.pojo.Archivepojo;
import com.util.MybatisSessionFactory;

public class ArchiveService {
	SqlSession session = MybatisSessionFactory.getSqlSession();
	ArchiveDao c = session.getMapper(ArchiveDao.class);
//添加Archive表的数据
	public void addarchive(@Param("user_id") String user_id,
			@Param("archive_id") String archive_id,
			@Param("identity") String identity, @Param("name") String name,
			@Param("gender") String gender, @Param("birthday") String birthday,
			@Param("date_retire1") String date_retire1,
			@Param("date_retire2") String date_retire2, @Param("sp") String sp,
			@Param("fc") String fc, @Param("title") String title,
			@Param("seniority") String seniority) {
		c.addArchive(user_id, archive_id, identity, name, gender, birthday,
				date_retire1, date_retire2, sp, fc, title, seniority);
		session.commit();
	}
//修改数据
	public void update(@Param("id") String id,
			@Param("user_id") String user_id,
			@Param("archive_id") String archive_id,
			@Param("identity") String identity, @Param("name") String name,
			@Param("gender") String gender, @Param("birthday") String birthday,
			@Param("date_retire1") String date_retire1,
			@Param("date_retire2") String date_retire2, @Param("sp") String sp,
			@Param("fc") String fc, @Param("title") String title,
			@Param("seniority") String seniority) {
		c.update(id, user_id, archive_id, identity, name, gender, birthday,
				date_retire1, date_retire2, sp, fc, title, seniority);
		session.commit();
	}
//模糊查询
	public List<Archivepojo> query(@Param("user_id") String user_id,
			@Param("archive_id") String archive_id,
			@Param("identity") String identity, @Param("name") String name,
			@Param("gender") String gender, @Param("birthday") String birthday,
			@Param("date_retire1") String date_retire1,
			@Param("date_retire2") String date_retire2, @Param("sp") String sp,
			@Param("fc") String fc, @Param("title") String title,
			@Param("seniority") String seniority) {
		List<Archivepojo> ren = c.query(user_id, archive_id, identity, name,
				gender, birthday, date_retire1, date_retire2, sp, fc, title,
				seniority);
		return ren;

	}
//首页的小框查询
	public List<Archivepojo> queryone(@Param("search") String search) {
		List<Archivepojo> ren = c.queryone(search);
		return ren;

	}
//查询ID
	public List<Archivepojo> query_one(String id) {
		List<Archivepojo> ren = c.query_one(id);
		return ren;
	}
//统计
	public List<Archivepojo> queryg(String user_id) {
		List<Archivepojo> ren = c.queryg(user_id);
		return ren;
	}
//查询ID
	public Map<String, Object> queryid() {
		return c.queryid();
	}
//登录
	public List<Archivepojo> queryall(@Param("archive_id") String archive_id,
			@Param("identity") String identity) {
		List<Archivepojo> ren = c.queryall(archive_id, identity);
		return ren;

	}
//删除
	public void dele(@Param("id") String id) {
		c.dele(id);
		session.commit();
	}
}
